<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8" content="#">
    <title>销售订单页面</title>
    <!-- 引入CSS -->
    <link rel="stylesheet" type="text/css"
          href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/easyui/css/demo.css">
    <!-- 引入JS -->
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/easyui/themes/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript"
            src="/easyui/js/validateExtends.js"></script>
    <script type="text/javascript" src="/common/js/common.js"></script>
    <script type="text/javascript"
            src="/common/js/order.js"></script>
    <script type="text/javascript">
        var login_name;
        //DOM加载完成后执行的回调函数
        $(function () {
            $.post("/system/getUserName", function (data) {
                login_name = data;
            })
            var table;
            //初始化datagrid
            $('#dataList').datagrid({
                iconCls: 'icon-more',//图标
                border: true,
                collapsible: false,//是否可折叠
                fit: true,
                method: "post",
                url: "/financeCheckPurPrice/getPurPrices?t" + new Date().getTime(),
                idField: 'id',
                singleSelect: false,//是否单选
                rownumbers: true,//行号
                pagination: true,//分页控件
                remoteSort: false,
                columns: [
                    [
                        {field: 'chk', checkbox: true, width: 50},
                        {field: 'id', title: 'ID', width: 35, sortable: true},
                        {
                            field: 'status', title: '物料状态', width: 90, sortable: true,
                            formatter: function (value, row, index) {
                                return getPurPirceStatus(value);
                            }
                        },
                        {
                            field: 'mainSupplier', title: '是否主供应商', width: 100, sortable: true,
                            formatter: function (value, row, index) {
                                return getPurPirceMainSupplier(value);
                            }
                        },
                        {field: 'supplierCode', title: '供应商编码', width: 100, sortable: true},
                        {field: 'supplierName', title: '供应商名字', width: 200, sortable: true},
                        {field: 'thingCode', title: '物料编码', width: 120, sortable: true},
                        {field: 'thingName', title: '物料名字', width: 200, sortable: true},
                        {field: 'unit', title: '单位', width: 40},
                        {field: 'purPrice', title: '采购价', width: 80},
                        {field: 'purGroup', title: '采购组', width: 60},
                        {field: 'purName', title: '采购员', width: 80},
                        {
                            field: 'remark', title: '备注', width: 150
                        }
                    ]
                ],
                toolbar: "#toolbar"//工具栏
            });

            //设置分页控件
            var p = $('#dataList').datagrid('getPager');
            $(p).pagination({
                pageSize: 10,//设置每页显示的记录条数,默认为10
                pageList: [10, 20, 30, 50, 100],//设置每页记录的条数
                beforePageText: '第',
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
            });

            $("#check").click(function () {
                var selectRows = $("#dataList").datagrid("getSelections");//返回所有选中的行,当没有选中的记录时,将返回空数组
                var selectLength = selectRows.length;
                if (selectLength === 0) {
                    $.messager.alert("消息提醒", "请选择想要审核的数据哟!", "warning");
                } else {
                    var ids = [];
                    $(selectRows).each(function (i, row) {
                        ids[i] = row.id;//将预审核行的id存储到数组中
                    });
                    $.ajax({
                        type: "post",
                        url: "/financeCheckPurPrice/checkPurPrice?t" + new Date().getTime(),
                        data: {ids: ids},
                        dataType: 'json',
                        success: function (data) {
                            if (data.success) {
                                $.messager.alert("消息提醒", "审核成功啦!", "info");
                                $("#dataList").datagrid("reload");//刷新表格
                                $("#dataList").datagrid("uncheckAll");//取消勾选当前页所有的行
                            } else {
                                $.messager.alert("消息提醒", "服务器端发生异常! 审核失败!", "warning");
                            }
                        }
                    });
                }
            });

            //销售组名和销售名搜索按钮的监听事件(将其值返回给Controller)
            $("#search-btn").click(function () {
                var chks = $("#orderAllStatus input:checked");
                var data = "";
                for (var i = 0; i < chks.length; i++) {
                    data += chks[i].value + ",";
                }
                $('#dataList').datagrid('load', {
                    personName: $('#search-saleName').textbox('getValue'),//获取销售名称
                    personGroup: $('#search-saleGroup').combobox('getValue'),//获取销售组名称
                    orderStatus: data
                });
            });
        })
        ;
    </script>
</head>
<body>

<!-- 销售列表信息 -->
<table id="dataList" cellspacing="0" cellpadding="0"></table>

<div id="toolbar">
    <!-- 学生,班级名搜索域 -->
    <div style="margin-left: 10px;">


        <div style="float: left;"><a id="check" href="javascript:" class="easyui-linkbutton"
                                     data-options="iconCls:'icon-add',plain:true">审核价格</a></div>
        <div style="float: left;" class="datagrid-btn-separator"></div>

        <!-- 商品名称搜索框 -->
        <a href="javascript:" class="easyui-linkbutton"
           data-options="iconCls:'icon-user-student',plain:true">销售组</a>
        <select id="search-techGroup" class="easyui-combobox" style="width: 250px">
        </select>

        <a href="javascript:" class="easyui-linkbutton"
           data-options="iconCls:'icon-user-student',plain:true">订单编号</a>
        <input id="search-itemCode" class="easyui-textbox"/>

        <!-- 搜索按钮 -->
        <a id="search-btn" href="javascript:" class="easyui-linkbutton"
           data-options="iconCls:'icon-search',plain:true">搜索</a>
    </div>

</div>


</body>
</html>